package com.yunian.common.advice;

import com.yunian.common.execption.AdExecption;
import com.yunian.common.execption.PlanExecption;
import com.yunian.common.vo.CommonResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionAdvice {

    @ExceptionHandler(value = AdExecption.class)
    public CommonResponse<String> handlerException(AdExecption adExecption){

        CommonResponse commonResponse = new CommonResponse<>(-1,"error");
        commonResponse.setData(adExecption.getMessage());
        return commonResponse;

    }


    @ExceptionHandler(value = PlanExecption.class)
    public CommonResponse<String> handlerPlanException(PlanExecption planExecption){
        CommonResponse commonResponse = new CommonResponse<>(-1,"error");
        commonResponse.setData(planExecption.getMessage());
        return commonResponse;
    }



}
